package com.csun.cmny.provider.model.enums;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * @Auther: chisj chisj@foxmal.com
 * @Date: 2019-10-12 16:10
 * @Description:
 */
public enum OmcCurTaskQueryEnum {

    /**
     * online omc convert type enum.
     */
    /*
     * 调房调级待审批查询
     */
    ReviseCurTaskQuery("ReviseCurTaskQuery", "调房调级待审批查询"),
    /**
     * 老人出院待审批查询
     */
    OFFLINE("OldOutCurTaskQuery", "老人出院待审批查询");

    /**
     * The Key.
     */
    String code;
    /**
     * The Value.
     */
    String name;

    OmcCurTaskQueryEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * Gets key.
     *
     * @return the key
     */
    public String getCode() {
        return code;
    }

    /**
     * Gets value.
     *
     * @return the value
     */
    public String getName() {
        return name;
    }

    /**
     * 获取key获取value
     *
     * @param code key
     *
     * @return value value
     */
    public static String getName(String code) {
        for (OmcCurTaskQueryEnum ele : OmcCurTaskQueryEnum.values()) {
            if (code.equals(ele.getCode())) {
                return ele.getName();
            }
        }
        return null;
    }

    /**
     * 根据key获取该对象
     *
     * @param code key
     *
     * @return this enum
     */
    public static OmcCurTaskQueryEnum getEnum(String code) {
        for (OmcCurTaskQueryEnum ele : OmcCurTaskQueryEnum.values()) {
            if (code.equals(ele.getCode())) {
                return ele;
            }
        }
        return null;
    }

    /**
     * 获取List集合
     *
     * @return List list
     */
    public static List<OmcCurTaskQueryEnum> getList() {
        return Arrays.asList(OmcCurTaskQueryEnum.values());
    }


    /**
     * 获取map类型集合
     *
     * @return Map类型List集合 map 2 list
     */
    public static List<Map<String, String>> getMap2List() {
        List<Map<String, String>> list = Lists.newArrayList();
        for (OmcCurTaskQueryEnum ele : OmcCurTaskQueryEnum.values()) {
            Map<String, String> map = Maps.newHashMap();
            map.put("code", ele.getCode());
            map.put("name", ele.getName());
            list.add(map);
        }
        return list;
    }
}
